﻿module Sustainalytics.GCCS {

    import Common = Sustainalytics.Common;

    export class GCPrincipleEventIndicatorImpactService implements IGCPrincipleEventIndicatorImpactService {

        constructor(
            private $q: ng.IQService,
            private $http: ng.IHttpService,
            private notificationFactory: Common.INotificationFactory,
            private staticObjects: Common.IStaticObjects) {
        }

        public GetByPrincipleSummaryId(principleSummaryId: string): ng.IPromise<GCPrincipleEventIndicatorImpactDto[]> {
            var def = this.$q.defer();

            var httpPromise: ng.IHttpPromise<GCPrincipleEventIndicatorImpactDto[]> = this.$http.get('/gccsserv/api/v1/gcprincipleeventindicatorimpact?principleSummaryId=' + principleSummaryId);

            httpPromise
                .success(function (data) {
                    def.resolve(data);
                })
                .error(function (data, status, headers, config) {
                    def.reject({ data: data, status: status, headers: headers, config: config });
                });

            return def.promise;
        }
    }


    angular.module('Sustainalytics.GCCS').service('GCPrincipleEventIndicatorImpactService',
        ['$q', '$http', 'notificationFactory', 'staticObjects', GCPrincipleEventIndicatorImpactService]);
} 